package com.example.moshudriver.protocol;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.external.activeandroid.DataBaseModel;
import com.external.activeandroid.annotation.Column;
import com.external.activeandroid.annotation.Table;

@Table(name = "ORDER_INFO")
public class COUPON_INFO  extends DataBaseModel
{



     @Column(name = "coupon")
     public COUPON   coupon;

     @Column(name = "cash_id")
     public String cash_id;
     
     @Column(name = "state")
     public int state;
     
     @Column(name = "use_time")
     public String use_time;
     
     @Column(name = "mount")
     public String mount;
     
    


     

     public void  fromJson(JSONObject jsonObject)  throws JSONException
     {
          if(null == jsonObject){
            return ;
           }

          JSONArray subItemArray;
        
          COUPON  coupon = new COUPON();
          coupon.fromJson(jsonObject.optJSONObject("coupon"));
          this.coupon = coupon;

          this.cash_id = jsonObject.optString("cash_id");
          this.use_time = jsonObject.optString("use_time");
          this.mount = jsonObject.optString("mount");
          this.state = jsonObject.optInt("state");
          

        
          return ;
     }

     public JSONObject  toJson() throws JSONException 
     {
          JSONObject localItemObject = new JSONObject();
          JSONArray itemJSONArray = new JSONArray();
       
          if(null != coupon)
          {
            localItemObject.put("coupon", coupon.toJson());
          }
          localItemObject.put("cash_id", cash_id);
          localItemObject.put("state", state);
          localItemObject.put("use_time", use_time);
        
          localItemObject.put("mount", mount);
          return localItemObject;
     }

}
